package com.jaychen.eureka.client.domain;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 续约
 *
 * @Author Jay Chen
 * @Date 2020/10/23 13:20
 */
public class Lease<T> {

    private static final Logger logger = LoggerFactory.getLogger(Lease.class);

    /**
     * 默认续约期限时间
     */
    public static final int DEFAULT_LEASE_DURATION = 90;

    private T holder;

    /**
     * 最后更新时间
     */
    private Long lastUpdateTimestamp;

    /**
     * 租约时间
     */
    private Long duration;

    public Lease(T r, Long durationInSecs) {
        holder = r;
        lastUpdateTimestamp = durationInSecs;
        duration = lastUpdateTimestamp * 1000;
    }

    public static Logger getLogger() {
        return logger;
    }

    public T getHolder() {
        return holder;
    }

    public Long getLastUpdateTimestamp() {
        return lastUpdateTimestamp;
    }

    public void setLastUpdateTimestamp(Long lastUpdateTimestamp) {
        this.lastUpdateTimestamp = lastUpdateTimestamp;
    }

    public Long getDuration() {
        return duration;
    }
}
